package com.bluezone.dec.system.controller;

import com.bluezone.dec.common.JsonResult;
import com.bluezone.dec.system.service.MonitorAlarmService;
import com.bluezone.dec.system.service.ParkEnvironmentProtectStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author HHL
 * @description 园区环保情况统计
 * @date 2018/9/28 - 9:25
 */
@Api(tags = "园区环保情况统计")
@RequestMapping("/dec/park-environmental")
@RestController
public class ParkEnvironmentProtectStatisticsController {

    @Autowired
    private ParkEnvironmentProtectStatisticsService protectStatisticsService;

    @Autowired
    private MonitorAlarmService monitorAlarmService;

    @ApiOperation("环保事故行政处罚情况统计")
    @GetMapping("/punishment")
    public JsonResult getAdministrativePenaltyCount() {
        Map<String, Object> penaltyResult = protectStatisticsService.getAdministrativePenalStatus();
        return new JsonResult().ok(penaltyResult);
    }

    @ApiOperation("园区环保情况总数统计")
    @GetMapping("/title")
    public JsonResult environmentalCount() {

        Map<String, Object> resultMap = new HashMap<>();

        /* 环境监控预警情况 */
        int envMonitorStatusCount = monitorAlarmService.getEnvironmentMonitorStatus();
        /* 环保制度管理情况 */
        int protectRulesManageCount = protectStatisticsService.getEnvProtectRulesManageStatus();
        /* 获取环保事故处理情况 */
        int accidentHandleCount = protectStatisticsService.getAccidentHandleStatus();

        resultMap.put("envMonitorStatusCount", envMonitorStatusCount);
        resultMap.put("protectRulesManageCount", protectRulesManageCount);
        resultMap.put("accidentHandleCount", accidentHandleCount);

        return new JsonResult().ok(resultMap);
    }

    @ApiOperation("环境信访情况统计")
    @GetMapping("/information")
    public JsonResult getEnvironmentLetterStatus() {
        Map<String, Object> result = protectStatisticsService.getEnvironmentLetterStatus();
        return new JsonResult().ok(result);
    }

    @ApiOperation("环境污染物总量控制情况")
    @GetMapping("/pollution-control")
    public JsonResult getPollutionControl() {
        return new JsonResult().ok(protectStatisticsService.getPollutionControl());
    }

}
